package org.quickstart.dispatch.handlers;

import net.customware.gwt.dispatch.server.ActionHandler;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;
import org.quickstart.api.action.UpdateContactAction;
import org.quickstart.model.Contact;

/**
 * EXAMPLE
 *
 * @author Yoav Aharoni
 */
public class UpdateContactsHandler implements ActionHandler<UpdateContactAction, UpdateContactAction.Result> {
	public UpdateContactsHandler() {
	}

	@Override
	public UpdateContactAction.Result execute(UpdateContactAction updateContactAction, ExecutionContext executionContext) throws ActionException {
		return new UpdateContactAction.Result(new Contact(updateContactAction.getName(), ""), updateContactAction.getContact());
	}

	@Override
	public void rollback(UpdateContactAction updateContactAction, UpdateContactAction.Result result, ExecutionContext executionContext) throws ActionException {
	}

	@Override
	public Class<UpdateContactAction> getActionType() {
		return UpdateContactAction.class;
	}
}